home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-04-12 | 2.2 KB | 84 lines | [TEXT/PJMM] |
- unit DoCommand;
-
- interface
- uses
- Globals, Report;
-
- function DoCommand (mresult: Longint): Boolean;
-
- implementation
-
- {Handle a command given through a menu selection}
- {############################ DoCommand ##############################}
-
- { We carry out the command indicated by mResult.}
- { If it was Quit, we return true, else false. Since the menu was}
- { highlighted by MenuSelect, we must finish by unhighlighting it}
- { to indicate we're done.}
-
- function DoCommand (mresult: Longint): Boolean;
- var
- refnum: LongInt;
- themenu, theitem: LongInt;
- name: Str255;
- saveport: GrafPtr; (* for saving current port in when opening a desk accessory *)
- astr: StringHandle; (* Handle for a utility string *)
- returns: Boolean;
-
- begin
- returns := false; (* assume Quit not selected *)
- themenu := HiWord(mresult); (* get the menu selected *)
- theitem := LoWord(mresult); (* ... and the Item of that menu *)
- case (themenu) of
- 0:
- ; (* user made no selection; do nothing *)
-
- applemenu:
-
- if (theitem = 1) then
- begin (* get string, and tell about Skel *)
-
- (* }
- { It's important not to pass Report a de-referenced}
- { Handle; if Report were in another segment, loading}
- { it could cause a memory compaction; the de-referenced}
- { Handle could become invalid. Watch out for this}
- { and similar nasties everywhere in your program.}
- { See the Memory Manager and the Segment Loader.}
- {*)
- astr := GetString(aboutskelid);
-
- Report(astr);
- end
- else
- begin (* run a desk accessory; make sure port is preserved *)
- GetPort(saveport);
- GetItem(mymenus[applemenu], theitem, name); (* get name *)
- refnum := OpenDeskAcc(name);(* run the desk accessory *)
- SetPort(saveport);
- end;
-
- filemenu:
- case (theitem) of
- irattle: (* Rattle *)
- begin
- astr := GetString(rattleid);
- Report(astr);
- end;
- ifrighten: (* Frighten *)
- begin
- astr := GetString(frightenid);
- Report(astr);
- end;
- iquit:
- returns := true;(* Quit *)
-
- end; (* fileMenu case *)
-
- end; (* menu case *)
-
- HiliteMenu(0); (* turn off hilighting on the menu just used *)
- DoCommand := returns;
- end; (* DoCommand *)
-
- end.